package org.simple.exception;

import org.simple.constant.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * 统一异常处理
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

	@ExceptionHandler(value = Exception.class)
	public Result handler(Exception e) {
		log.error("【服务器错误】",e);
		return Result.error("服务器异常");
	}

	@ExceptionHandler(value = BusinessException.class)
	public Result handler(BusinessException e) {
		log.error("【业务异常】",e);
		return Result.error("业务异常");
	}

}
